<template>
  <div class="component-list">
    <el-row :gutter="20">
      <el-col :span="12" v-for="(item, i) in list" :key="i">
        <li @dragstart="handleDragStart($event, i)" draggable>
          <i :class="`el-icon-${item.icon}`"></i>
          <span>{{ item.label }}</span>
        </li>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { list } from "../component-list.js";
export default {
  data() {
    return {
      list,
    };
  },
  methods: {
    handleDragStart(e, index) {
      e.dataTransfer.setData("index", index);
    },
  },
};
</script>

<style lang="less" scoped>
.component-list {
  height: 60%;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0 20px;
  li {
    background-color: #ccc;
    text-align: center;
    margin: 10px 0;
    height: 30px;
    font-size: 12px;
    line-height: 30px;
    cursor: pointer;
    span {
      margin-left: 5px;
    }
  }
}
</style>
